#include <stdio.h>

#define LEN 10

void swap ( int arr[] );

void output ( int arr[] );

int main ( int argc, char const *argv[] ) {
    int arr[LEN];
    int i;
    printf("Please input 10 numbers:\t");
    for ( i = 0; i < LEN; i++ ) {
        scanf("%d",&arr[i]);
    }
    output(arr);
    swap(arr);
    output(arr);
    return 0;
}

void swap ( int arr[] ) {
    int max = arr[0];
    int min = arr[0];
    int tmp;
    int i;
    int j = 0;
    /* max */
    for ( i = 0; i < LEN; i++ ) {
        if ( arr[i] > max ) {
            max = arr[i];
            j = i;
        }
    }
    tmp = arr[LEN-1];
    arr[LEN-1] = max;
    arr[j] = tmp;
    /* max */
    j = 0;
    for ( i = 0; i < LEN; i++ ) {
        if ( arr[i] < min ) {
            min = arr[i];
            j = i;
        }
    }
    tmp = arr[0];
    arr[0] = min;
    arr[j] = tmp;
}

void output ( int arr[] ) {
    int i;
    for ( i = 0; i < LEN; i++ ) {
        printf("%d\t",arr[i]);
    }
    printf("\n");
}